﻿//页面加载
$(document).ready(function () {
    $("#btnSave").bind("click", btnSave_click);
    $("#btnCancel").bind("click", btnCancel_click);
})

function btnSave_click() {
    //异步提交表单,表单中input元素必须设置name 属性
    var v_code = $("#Code").val();
    if (v_code == "") {
        alert("请输入卡号");
        return;
    }
    var v_RealName = $("#RealName").val();
    if (v_RealName == "") {
        alert("请输入真实姓名");
        return;
    }
    var v_Phone = $("#Phone").val();
    if (v_Phone == "") {
        alert("请输联系电话");
        return;
    }
    var v_state = $("#Dic_State").val();
    if (v_state == "0")
    {
        alert("请选择卡状态");
        return;
    }

    $.post("/VipCard/Save?Action=Update", $("#fmSave").serialize(), function (result) {
        if (result.code == "OK") {
            alert("数据保存成功!");
            window.location.href = "/VipCard/Index";
        }
        else {
            alert( result.msg);
        }
    });
}


function btnCancel_click() {
    window.history.go(-1);
}